package main

import (
	"github.com/asim/go-micro/plugins/registry/consul/v4"
	"todoSrv/handler"
	pb "todoSrv/proto"

	"go-micro.dev/v4"
	"go-micro.dev/v4/logger"
)

var (
	service = "todosrv"
	version = "latest"
)

func main() {
	//注册服务
	consulReg := consul.NewRegistry()
	srv := micro.NewService(
		micro.Name(service),
		micro.Address("127.0.0.1:9092"),
		micro.Version(version),
		micro.Registry(consulReg),
	)

	// Register handler
	if err := pb.RegisterTodoSrvHandler(srv.Server(), new(handler.TodoSrv)); err != nil {
		logger.Fatal(err)
	}
	// Run service
	if err := srv.Run(); err != nil {
		logger.Fatal(err)
	}
}
